from django.shortcuts import render,HttpResponse

# def ufile(request):
#     return render(request,'uploadFile.html',{})


# def getfilepost(request):
#     """
#     展示上传文件的页面
#     :param request:
#     :return:
#     """
#     post_res = request.POST['username']
#     file_res = request.FILES['file']
#     print(file_res)
#     print(post_res)
#     exit()
def upload_file(request):
    if request.method == 'GET':
        return render(request,'uploadFile.html',{})

    if request.method == 'POST':
        myfile = request.FILES['file']
        with open('uploaded_files/' + myfile.name, 'wb+') as destination:
            for chunk in myfile.chunks():
                destination.write(chunk)
        return HttpResponse('成功')